package com.enjoy.concurrent.ch3;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Test {
    private static int sum = 0;
    private static final Object o = new Object();

    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                for (int j = 0; j < 10000; j++) {
                    synchronized (o) {
                        sum++;
                    }
                }
                log.info("执行完了");
            }, "t" + i).start();
        }

        Thread.sleep(10000);
        log.info("sum:{}", sum);
    }
}
